package com.bdqn.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bdqn.mapper.RoleMapper;
import com.bdqn.mapper.UserMapper;
import com.bdqn.pojo.Role;
import com.bdqn.service.RoleService;
import jakarta.annotation.Resource;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
  @Resource
  private RoleMapper roleMapper;

  @Resource
  private UserMapper userMapper;

  @Override
  public Page<Role> findPage(Page page, String roleName) {
    return roleMapper.findPage(page, roleName);
  }

  @Override
  @Cacheable(value = "role", key = "'all'", unless = "#result==null")
  public List<Role> findAll() {
    return super.list();
  }

  @Override
  public boolean deleteById(Long id) {
    roleMapper.deleteById(id);
    userMapper.deleteById(id);
    return true;

  }
}




